package com.eascs.ticket.schedule.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eascs.ticket.common.entity.StatusConstant;
import com.eascs.ticket.common.service.BaseSevice;
import com.eascs.ticket.schedule.entity.ScheduleTicket;
import com.eascs.ticket.schedule.entity.ScheduleTicketUpdate;

@Service
public class ScheduleTicketService extends BaseSevice {

	public List<Object[]> getAllScheduleTickets() {
		return this.proxyDao.findObjectsList("sql.schedule.ticket.search");
	}

	public List<ScheduleTicket> getValidScheduleTicketList() {
		ScheduleTicket scheduleTicket = new ScheduleTicket();
		scheduleTicket.setStatus(StatusConstant.STATUS_OK);
		return this.proxyDao.findEntitysWithAny(scheduleTicket);
	}

	public ScheduleTicket getScheduleTicketById(String id) {
		return this.proxyDao.getById(ScheduleTicket.class, id);
	}

	@Transactional(transactionManager = "ticketTransactionManager")
	public ScheduleTicket insertScheduleTicket(ScheduleTicket scheduleTicket) {
		this.proxyDao.insert(scheduleTicket);
		return scheduleTicket;
	}

	@Transactional(transactionManager = "ticketTransactionManager")
	public ScheduleTicketUpdate updateScheduleTicket(ScheduleTicketUpdate scheduleTicketUpdate) {
		this.proxyDao.updateById(scheduleTicketUpdate);
		return scheduleTicketUpdate;
	}

}
